import {createRouter, createWebHistory} from 'vue-router'
import constantRoutes from './constant-routes.ts'
import toRoutes from "@/router/toRoutes.ts";
import {setupRouterGuard} from "@/router/guard.ts";

const router =createRouter({
    //路由模式
    history: createWebHistory(),
    routes: toRoutes(constantRoutes),
    //滚动行为
    scrollBehavior() {
        //一滚动，水平方向归零，top方向也归零
        return{
            left: 0,
            top: 0
        }
    }
})

//注册路由守卫
setupRouterGuard(router)

export default router